<script setup>
import {get} from "@/net";
import {useStore} from "@/stores";
import router from "@/router";
import {ElMessage} from "element-plus";

const store = useStore()

if(store.auth.user == null) {

    //初始化个人信息
    get('/api/user/me', (message) => {
        store.auth.user = message
        router.push('/index')
        if (store.revise.needToRevise == null){
            get('/vocabulary/getReviseList?userId='+store.auth.user.id,(message)=>{
                console.log(message)
                store.revise.needToRevise = message
                ElMessage.success('复习列表更新成功！')
            })
        }
    }, () => {
        store.auth.user = null
    })
}

if (store.learn.wordLists == null){
    get('/vocabulary/getLists',(message)=>{
        store.learn.wordLists = message
        ElMessage.success('单词库更新成功！')
    })
}


</script>

<template>
    <router-view/>
</template>

<style scoped>

</style>